/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package weka.attributeSelection.semiAS.semiClusterAS;

/**
 *
 * @author Administrator
 */
public class FeatCenterEval implements Score {

    private int[] m_indicator;
    private double[][] m_distance;

    public FeatCenterEval(final int[] indicator, final double[][] distance) {
        m_indicator = indicator;
        m_distance = distance;
    }

    public double getScore(int i) {
        return 1 - calDisAve(i);
    }

    private double calDisAve(int i) {
        double disAve = 0.0;
        int c = m_indicator[i] - 1;
        int n = 0;
        for (int j = 0; j < m_distance.length; j++) {
            if (j == i) {
                continue;
            }
            if (m_indicator[j] - 1 == c) {
                disAve = disAve + m_distance[i][j];
                n++;
            }
        }
        return disAve / n;
    }
}
